home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Comm
/
term-source.lha
/
Extras
/
Source
/
term-Source.lha
/
ASCIIPanel.c
next >
Wrap
C/C++ Source or Header
|
1995-06-17
|
10KB
|
454 lines
/*
** ASCIIPanel.c
**
** User interface for built-in ASCII transfer routines
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_BYTES=1000,GAD_INFORMATION,GAD_CHARDELAY,GAD_LINEDELAY,
GAD_PACING,GAD_QUIET_TRANSFER,GAD_SKIP,GAD_ABORT
};
STATIC struct LayoutHandle *ASCIIHandle;
STATIC struct List MessageList;
STATIC LONG MessageCount;
STATIC STRPTR __saveds
ShowTime(struct Gadget *SomeGadget,WORD Level)
{
return(LocaleSeconds(Level));
}
struct Window * __regargs
CreateASCIIWindow(BYTE Send)
{
struct IBox Bounds;
NewList(&MessageList);
MessageCount = 0;
if(ASCIIHandle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
TAG_DONE))
{
struct Window *PanelWindow;
LT_New(ASCIIHandle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0000,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, BOX_KIND,
LA_ID, GAD_BYTES,
LABX_FirstLabel, MSG_ASCIIPANEL_BYTES_GAD,
LABX_LastLabel, MSG_ASCIIPANEL_LINES_GAD,
LABX_ReserveSpace, TRUE,
LA_Chars, 50,
TAG_DONE);
LT_New(ASCIIHandle,
LA_Type, LISTVIEW_KIND,
LA_LabelID, MSG_ASCIIPANEL_INFORMATION_GAD,
LA_LabelPlace, PLACE_LEFT,
LA_ID, GAD_INFORMATION,
LA_Lines, 2,
LALV_MaxGrowX, 70,
LALV_MaxGrowY, 10,
LALV_CursorKey, TRUE,
GTLV_ReadOnly, TRUE,
GTLV_Labels, &MessageList,
TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
if(Send)
{
LT_New(ASCIIHandle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0003,
LAGR_LastAttributes, TRUE,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, SliderType,
LA_LabelID, MSG_ASCIIPANEL_CHAR_DELAY_GAD,
LA_ID, GAD_CHARDELAY,
GTSL_Min, 0,
GTSL_Max, 10 * 100,
LA_WORD, &Config -> TransferConfig -> CharDelay,
GTSL_LevelFormat, "%s s",
GTSL_DispFunc, ShowTime,
TAG_DONE);
LT_New(ASCIIHandle,
LA_Type, SliderType,
LA_LabelID, MSG_ASCIIPANEL_LINE_DELAY_GAD,
LA_ID, GAD_LINEDELAY,
GTSL_Min, 0,
GTSL_Max, 10 * 100,
LA_WORD, &Config -> TransferConfig -> LineDelay,
GTSL_LevelFormat, "%s s",
GTSL_DispFunc, ShowTime,
TAG_DONE);
LT_New(ASCIIHandle,
LA_Type, CYCLE_KIND,
LA_LabelID, MSG_ASCIIPANEL_TEXT_PACING_GAD,
LA_ID, GAD_PACING,
LA_UBYTE, &Config -> TransferConfig -> PacingMode,
LACY_FirstLabel, MSG_ASCIIPANEL_DIRECT_TXT,
LACY_LastLabel, MSG_ASCIIPANEL_KEYDELAY_TXT,
TAG_DONE);
LT_New(ASCIIHandle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_ASCIIPANEL_QUIET_TRANSFER_GAD,
LA_ID, GAD_QUIET_TRANSFER,
LA_BYTE, &Config -> TransferConfig -> QuietTransfer,
TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
LT_New(ASCIIHandle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, XBAR_KIND,
LAXB_FullSize, TRUE,
TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
LT_New(ASCIIHandle,LA_Type,HORIZONTAL_KIND,
LAGR_SameSize, TRUE,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_TRANSFERPANEL_SKIP_CURRENT_FILE_GAD,
LA_ID, GAD_SKIP,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(ASCIIHandle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_TRANSFERPANEL_ABORT_ENTIRE_TRANSFER_GAD,
LA_ID, GAD_ABORT,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
}
else
{
LT_New(ASCIIHandle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(ASCIIHandle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
LT_New(ASCIIHandle,
LA_Type, HORIZONTAL_KIND,
TAG_DONE);
{
LT_New(ASCIIHandle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_TRANSFERPANEL_ABORT_ENTIRE_TRANSFER_GAD,
LA_ID, GAD_ABORT,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(ASCIIHandle);
}
}
LT_EndGroup(ASCIIHandle);
}
Bounds . Left = WindowLeft + Window -> LeftEdge;
Bounds . Top = WindowTop + Window -> TopEdge;
Bounds . Width = WindowWidth;
Bounds . Height = WindowHeight;
// if(PanelWindow = LT_Layout(ASCIIHandle,Send ? LocaleString(MSG_ASCIIPANEL_SENDING_TXT) : LocaleString(MSG_ASCIIPANEL_RECEIVING_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
if(PanelWindow = LT_Layout(ASCIIHandle,Send ? LocaleString(MSG_ASCIIPANEL_SENDING_TXT) : LocaleString(MSG_ASCIIPANEL_RECEIVING_TXT),&Bounds,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
// LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
TAG_DONE))
{
ULONG IntuiLock = LockIBase(NULL);
BYTE Activate,Move;
GuideContext(CONTEXT_ASCII);
if(Config -> MiscConfig -> AlertMode == ALERT_SCREEN || Config -> MiscConfig -> AlertMode == ALERT_BEEP_SCREEN)
Move = Activate = TRUE;
else
{
if(IntuitionBase -> ActiveScreen == PanelWindow -> WScreen)
Activate = TRUE;
else
Activate = FALSE;
}
UnlockIBase(IntuiLock);
if(Move)
{
if(PanelWindow -> WScreen -> LeftEdge > 0)
{
if(PanelWindow -> WScreen -> TopEdge > 0)
MoveScreen(PanelWindow -> WScreen,-PanelWindow -> WScreen -> LeftEdge,-PanelWindow -> WScreen -> TopEdge);
else
MoveScreen(PanelWindow -> WScreen,-PanelWindow -> WScreen -> LeftEdge,0);
}
else
{
if(PanelWindow -> WScreen -> TopEdge > 0)
MoveScreen(PanelWindow -> WScreen,0,-PanelWindow -> WScreen -> TopEdge);
}
WindowToFront(PanelWindow);
ScreenToFront(PanelWindow -> WScreen);
}
if(Activate)
ActivateWindow(PanelWindow);
PushWindow(PanelWindow);
return(PanelWindow);
}
LT_DeleteHandle(ASCIIHandle);
ASCIIHandle = NULL;
}
return(NULL);
}
VOID __regargs
DeleteASCIIWindow(struct Window *Window,BYTE WaitForIt)
{
if(WaitForIt && Window && ASCIIHandle)
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
WORD i;
for(i = GAD_CHARDELAY ; i <= GAD_SKIP ; i++)
LT_SetAttributes(ASCIIHandle,i,GA_Disabled,TRUE,TAG_DONE);
do
{
if(Wait(PORTMASK(Window -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(Message = (struct IntuiMessage *)GT_GetIMsg(Window -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(ASCIIHandle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW || (MsgClass == IDCMP_GADGETUP && MsgGadget -> GadgetID == GAD_ABORT))
Done = TRUE;
}
}
while(!Done);
}
if(Window && ASCIIHandle)
PopWindow();
if(ASCIIHandle)
{
LT_DeleteHandle(ASCIIHandle);
ASCIIHandle = NULL;
}
if(MessageCount)
{
FreeList(&MessageList);
MessageCount = 0;
}
}
VOID __stdargs
AddASCIIMessage(struct Window *Window,STRPTR Message,...)
{
STATIC UBYTE __far TempBuffer[256];
struct Node *Node;
va_list VarArgs;
va_start(VarArgs,Message);
VSPrintf(TempBuffer,Message,VarArgs);
va_end(VarArgs);
if(Node = CreateNode(TempBuffer))
{
if(MessageCount == 100)
{
FreeVecPooled(RemHead(&MessageList));
MessageCount = 99;
}
LT_SetAttributes(ASCIIHandle,GAD_INFORMATION,
GTLV_Labels,~0,
TAG_DONE);
AddTail(&MessageList,Node);
LT_SetAttributes(ASCIIHandle,GAD_INFORMATION,
GTLV_Labels, &MessageList,
GTLV_Top, MessageCount,
GTLV_MakeVisible, MessageCount,
TAG_DONE);
MessageCount++;
}
}
VOID __regargs
UpdateASCIIWindow(struct Window *Window,LONG Bytes,LONG MaxBytes,LONG Lines)
{
if(Bytes != -1)
{
UBYTE LocalBuffer[40];
if(MaxBytes)
{
LONG Percent = (100 * Bytes) / MaxBytes;
if(Percent > 100)
Percent = 100;
if(LocaleBase)
SPrintf(LocalBuffer,"%lD (%ld%%)",Bytes,Percent);
else
SPrintf(LocalBuffer,"%ld (%ld%%)",Bytes,Percent);
}
else
SPrintf(LocalBuffer,ConvNumber,Bytes);
LT_SetAttributes(ASCIIHandle,GAD_BYTES,
LABX_Index, 0,
LABX_Text, LocalBuffer,
TAG_DONE);
}
if(Lines != -1)
{
UBYTE LocalBuffer[40];
SPrintf(LocalBuffer,ConvNumber,Lines);
LT_SetAttributes(ASCIIHandle,GAD_BYTES,
LABX_Index, 1,
LABX_Text, LocalBuffer,
TAG_DONE);
}
}
BYTE __regargs
HandleASCIIWindow(struct Window *Window)
{
struct IntuiMessage *Message;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
while(Message = (struct IntuiMessage *)GT_GetIMsg(Window -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(ASCIIHandle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
return(1);
if(MsgClass == IDCMP_MOUSEMOVE)
{
SendSetup();
ConfigChanged = TRUE;
}
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_PACING:
case GAD_CHARDELAY:
case GAD_LINEDELAY:
ASCIISendSetup();
ConfigChanged = TRUE;
break;
case GAD_QUIET_TRANSFER:
ConfigChanged = TRUE;
break;
case GAD_ABORT:
return(1);
case GAD_SKIP:
return(2);
}
}
}
return(0);
}